package com.accountant.travelaccountant;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.GridLayout.LayoutParams;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;

public class ChooseAccount2_GridviewBottom
		extends BaseAdapter {

	ChooseAccount2 chooseAccount2;

	Activity activity = new Activity();
	/* String array for string the names of all the buttons */
	String listOfButtonNames[] = { "Rename the account",
			"Delete the account", "Open account statistics" };
	Integer listOfIds[] = { R.id.btnRenameAccount2, R.id.deleteAccount2,
			R.id.openAccountStatistics2 };
	Context context;

	public ChooseAccount2_GridviewBottom(
			Context context, ChooseAccount2 chooseAccount2) {
		this.context = context;
		this.chooseAccount2 = chooseAccount2;
	}

	@Override
	public int getCount() {
		return listOfButtonNames.length;
	}

	@Override
	public Object getItem(int arg0) {
		return listOfButtonNames[arg0];
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView textView = new TextView(context);
		textView.setText(listOfButtonNames[position]);
		textView.setBackgroundColor(chooseAccount2.getResources().getColor(R.color.Button_Color_Background));
		textView.setTextColor(chooseAccount2.getResources().getColor(R.color.Button_Color_Text));
		textView.setGravity(Gravity.CENTER);
		textView.setLayoutParams(new GridView.LayoutParams(
				LayoutParams.MATCH_PARENT, 50));
		textView.setId(listOfIds[position]);

		textView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.btnRenameAccount2:
					chooseAccount2.renameAccountTextview();
					break;
				case R.id.deleteAccount2:
					chooseAccount2.deleteAccountTextview();
					break;
				case R.id.openAccountStatistics2:
					chooseAccount2.openStatisticsTextview();
					break;
				default:
					break;
				}
			}
		});

		return textView;
	}

}
